package com.IM.commandType;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum CommandType {
    /**
     * 建立连接
     */
    CONNECTION(1001),
    /**
     * 聊天
     */
    CHAT(1002),
    /**
     * 加入群聊
     */
    JOIN_GROUP(1003),
    ERROR(-1);
    private  Integer code;
    public static CommandType match(Integer code){
        for (CommandType type:CommandType.values()
             ) {
            if(type.getCode().equals(code)){
                return type;
            }
        }
        return ERROR;
    }
}
